package com.ruowei.modules.wxpay.utils;

import java.security.PublicKey;

public class RSATest {

    public static void main(String[] args) throws Exception {
        String encBankAcctNo = "6217974650000161784"; //加密的银行账号
        //注意:这里的  pksc8_public.pem  是上一步获取微信支付公钥后经openssl 转化成PKCS8格式的公钥
        String keyfile = "D:/data/projects/bjwalk/pksc8_public.pem"; //读取PKCS8密钥文件
        PublicKey pub = RSAUtil.getPubKey(keyfile, "RSA");
        String rsa = "RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING";
        byte[] estr = RSAUtil.encrypt(encBankAcctNo.getBytes(), pub, 2048, 11, rsa);   //对银行账号进行加密
        encBankAcctNo = Base64.encode(estr);//并转为base64格式
        System.out.println(encBankAcctNo);
    }

    /**
     * getPubkey 1......
     * getPubkey 2......
     * b1.........
     * b2.........
     * b3.........
     * b4.........
     * b5.........
     * b6.........
     * b7.........
     * getPubkey 3......
     * Ze8ojI4rBUWaCAKx34dyVMtmI06PxeIH6AwhZjCJTOTGB0g8YfY1/r4tG9BDhhrEspyt8h/PFpyCuHKjRG/P2WzcSyl1w9EVQKSTa+n6h8JMClx6U6XsztSI5619Cg7ELhGsFJeS3Eeb5cM7bXfk1De/w08aiHJyKsFDYZiR0rCmV2b658yRDuzkrelaifjhggZjyN6cgJK30UnpBATve/ZY8/BTaio+Uivlngdf2nE7mQR0d8pszhRmngkLYn4lJA8AmOG53eYVqEnob0IG/+budM+X3vZWCf066KvtTur6P9edmHwkLFLdSEv4aGGehuttMpprU2MoPJ/ExHtYmQ==
     *
     * Process finished with exit code 0
     */

}
